package com.ruoyi.gis.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.gis.domain.SamLayer;
import com.ruoyi.gis.service.ISamLayerService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 图层信息Controller
 *
 * @author rww
 * @date 2023-12-19
 */
@RestController
@RequestMapping("/gis/samLayer")
public class SamLayerController extends BaseController
{
    @Autowired
    private ISamLayerService samLayerService;

    /**
     * 查询图层信息列表
     */
    @PreAuthorize("@ss.hasPermi('SamLayer:samLayer:list')")
    @GetMapping("/list")
    public TableDataInfo list(SamLayer samLayer)
    {
        startPage();
        List<SamLayer> list = samLayerService.selectSamLayerList(samLayer);
        return getDataTable(list);
    }

    /**
     * 导出图层信息列表
     */
    @PreAuthorize("@ss.hasPermi('SamLayer:samLayer:export')")
    @Log(title = "图层信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SamLayer samLayer)
    {
        List<SamLayer> list = samLayerService.selectSamLayerList(samLayer);
        ExcelUtil<SamLayer> util = new ExcelUtil<SamLayer>(SamLayer.class);
        util.exportExcel(response, list, "图层信息数据");
    }

    /**
     * 获取图层信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('SamLayer:samLayer:query')")
    @GetMapping(value = "/{layerId}")
    public AjaxResult getInfo(@PathVariable("layerId") Long layerId)
    {
        return success(samLayerService.selectSamLayerByLayerId(layerId));
    }

    /**
     * 新增图层信息
     */
    @PreAuthorize("@ss.hasPermi('SamLayer:samLayer:add')")
    @Log(title = "图层信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SamLayer samLayer)
    {
        return toAjax(samLayerService.insertSamLayer(samLayer));
    }

    /**
     * 修改图层信息
     */
    @PreAuthorize("@ss.hasPermi('SamLayer:samLayer:edit')")
    @Log(title = "图层信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SamLayer samLayer)
    {
        return toAjax(samLayerService.updateSamLayer(samLayer));
    }

    /**
     * 删除图层信息
     */
    @PreAuthorize("@ss.hasPermi('SamLayer:samLayer:remove')")
    @Log(title = "图层信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{layerIds}")
    public AjaxResult remove(@PathVariable Long[] layerIds)
    {
        return toAjax(samLayerService.deleteSamLayerByLayerIds(layerIds));
    }
}
